package com.example.util;

import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;

public class Util {
    public static void printIp(HttpServletRequest req){
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        long time = System.currentTimeMillis();
        Date date = new Date(time);
        String s = sdf.format(date);
        System.out.println(s+"*** ip: "+req.getRemoteAddr());
    }
    public static BigDecimal convertObject2BigDecimal(Map.Entry<String,Object> t){
        //return BigDecimal.valueOf((Double)t.getValue());
        return BigDecimal.valueOf(t.getValue() instanceof Integer?(Integer)t.getValue():(Double)t.getValue());
    }
    public static Integer convertObject2Integer(Map.Entry<String,Object> t){
        return Integer.valueOf(String.valueOf(t.getValue()));
    }
}
